/**
 * 
 */
package com.pmsco.pms.services.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.pmsco.pms.core.dao.CategoryDao;
import com.pmsco.pms.core.domain.Category;
import com.pmsco.pms.services.interfaces.CategoryService;

/**
 * @author Long Tran
 *
 */
public class CategoryServiceImpl implements CategoryService {
	private static final Logger logger = LoggerFactory.getLogger(CategoryServiceImpl.class);

	private static CategoryDao categoryDao;
	
	public Category getCategoryByName(String name) {
		logger.info("Start getCategoryByName");
		logger.debug("Name: " + name);
		Category category = new Category();
		category.setName(name);
		logger.info("End getCategoryByName");
		return categoryDao.loadCategory(category);
	}

	public Category getCategoryById(Long id) {
		logger.info("Start getCategoryById");
		logger.debug("Id: " + id);
		logger.info("End getCategoryById");
		return categoryDao.getCategoryById(id);
	}
	
	public void deleteCategory(Category category) {
		logger.info("Start deleteCategory");
		categoryDao.deleteCategory(category);
		logger.info("End deleteCategory");
	}

	public List<Category> listCategory(Category searchTemplate) {
		return categoryDao.listCategory(searchTemplate);
	}
	
	public List<Category> listCategory(String searchField, String searchString, String searchOper, String sidx, String sord, Integer page, Integer rows) {
		return categoryDao.listCategory(searchField, searchString, searchOper, sidx, sord, page, rows);
	}
	
	public Integer countListCategory(String searchField, String searchString, String searchOper) {
		return categoryDao.countListCategory(searchField, searchString, searchOper);
	}
	
	public void saveOrUpdateCategory(Category category) {
		categoryDao.saveOrUpdateCategory(category);
	}
	
	/**
	 * @param categoryDao the categoryDao to set
	 */
	public void setCategoryDao(CategoryDao categoryDao) {
		logger.info("Start setCategoryDao");
		logger.debug("Category Dao: " + categoryDao);
		this.categoryDao = categoryDao;
		logger.info("End setCategoryDao");
	}
	
}
